package com.huiyujinrong.qiangdanbao.activity.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.huiyujinrong.qiangdanbao.R;
import com.huiyujinrong.qiangdanbao.adapter.FindAdapter;
import com.huiyujinrong.qiangdanbao.widget.QQNaviView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 展业神器
 * Created by ZQXQ-Developer on 2017/6/29.
 */

public class ExhibitionActivity extends AppCompatActivity {
    @BindView(R.id.toolbar_Back)
    RelativeLayout back;
    @BindView(R.id.toolbar_Title)
    TextView tvTitle;


    @BindView(R.id.qq_view_bubble)
    QQNaviView mBubbleView;
    @BindView(R.id.qq_view_person)
    QQNaviView mPersonView;
    @BindView(R.id.qq_view_star)
    QQNaviView mStarView;

    @BindView(R.id.RecyclerView3)
    RecyclerView recyclerView;

    FindAdapter adapter;
    List<String> data = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ui_exhibition);
        ButterKnife.bind(this);
        tvTitle.setText("展业神器");
        back.setVisibility(View.VISIBLE);

        mBubbleView.setBigIcon(R.drawable.icon_zysq_business_g);
        mBubbleView.setSmallIcon(R.drawable.icon_zysq_business);

        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        recyclerView.setItemAnimator(new DefaultItemAnimator()); // 默认动画
        adapter = new FindAdapter(this, data);
        recyclerView.setAdapter(adapter);

        adapter.setmItemClickListener(new FindAdapter.OnItemClickListener() {
            @Override
            public void onItemClickListener(View pos) {
                startActivity(new Intent(ExhibitionActivity.this, ExhibitionEditActivity.class));
            }
        });
        initData();
    }

    private void initData() {
        data.add("http://img2.imgtn.bdimg.com/it/u=2850936076,2080165544&fm=206&gp=0.jpg");
        data.add("http://img3.imgtn.bdimg.com/it/u=524208507,12616758&fm=206&gp=0.jpg");
        data.add("http://img3.imgtn.bdimg.com/it/u=698582197,4250615262&fm=206&gp=0.jpg");
        data.add("http://img5.imgtn.bdimg.com/it/u=1467751238,3257336851&fm=11&gp=0.jpg");
        data.add("http://img2.imgtn.bdimg.com/it/u=4081165325,36916497&fm=21&gp=0.jpg");
        data.add("http://img4.imgtn.bdimg.com/it/u=4141168524,78676102&fm=21&gp=0.jpg");
        data.add("http://img3.imgtn.bdimg.com/it/u=698582197,4250615262&fm=206&gp=0.jpg");
        data.add("http://img3.imgtn.bdimg.com/it/u=2566161363,1140447270&fm=206&gp=0.jpg");
        adapter.notifyDataSetChanged();
    }

    @OnClick({R.id.toolbar_Back})
    public void onClicks(View v) {
        switch (v.getId()) {
            case R.id.toolbar_Back:
                finish();
                break;
        }
    }

    public void onClick(View view) {
        resetIcon();
        switch (view.getId()) {
            case R.id.qq_view_bubble:
                mBubbleView.setBigIcon(R.drawable.icon_zysq_business_g);
                mBubbleView.setSmallIcon(R.drawable.icon_zysq_business);
                Toast.makeText(this, "bubble", Toast.LENGTH_SHORT).show();
                break;
            case R.id.qq_view_person:
                mPersonView.setBigIcon(R.drawable.icon_zysq_festv_g);
                mPersonView.setSmallIcon(R.drawable.icon_zysq_festv);
                Toast.makeText(this, "bubble", Toast.LENGTH_SHORT).show();
                break;
            case R.id.qq_view_star:
                mStarView.setBigIcon(R.drawable.icon_zysq_fun_g);
                mStarView.setSmallIcon(R.drawable.icon_zysq_fun);
                Toast.makeText(this, "bubble", Toast.LENGTH_SHORT).show();
                break;
        }
    }

    private void resetIcon() {
        mBubbleView.setBigIcon(R.drawable.icon_zysq_business);
        mBubbleView.setSmallIcon(R.drawable.icon_zysq_business_g);

        mPersonView.setBigIcon(R.drawable.icon_zysq_festv);
        mPersonView.setSmallIcon(R.drawable.icon_zysq_festv_g);


        mStarView.setBigIcon(R.drawable.icon_zysq_fun);
        mStarView.setSmallIcon(R.drawable.icon_zysq_fun_g);
    }
}